import type { IProgramStatus } from "../types";

export function getProgramStatusSummary(
  status: IProgramStatus[],
  loop: number,
) {
  let hours = 0;
  let mins = 0;
  let second = 0;
  let steps = 0;
  status.forEach((item) => {
    hours += item.stepHour * item.segmentLoop * loop;
    mins += item.stepMinute * item.segmentLoop * loop;
    second += item.stepSecond * item.segmentLoop * loop;
    steps += item.segmentLoop * loop;
  });
  mins += Math.floor(second / 60);
  second %= 60;
  hours += Math.floor(mins / 60);
  mins %= 60;
  return { totalTime: `${hours}:${mins}:${second}`, totalSteps: steps };
}
